package com.facotry.controller;

import com.facotry.entity.depManage;
import com.facotry.entity.depManageVo;
import com.facotry.service.setService;
import com.facotry.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * --- 代码敲烂 月薪过万 ---
 *
 * @author 崔瑜航
 * @date 2024/7/22
 * @desc
 */
@RestController
@RequestMapping("/set/depManage")
public class setController {

    @Autowired
    private setService service;

    /**
     *查询所有部门
     */
    @GetMapping("/list")
    public R findAllDep(){
        List<depManageVo> vo = service.findAllDep();
        System.out.println("vo = " + vo);
        return R.ok(vo);
    }
    /**
     * 添加新车间
     */
    @PostMapping("/addDep")
    public R addDep(@RequestBody depManage depManage){
        System.out.println("depManage = " + depManage);
        boolean idadd = service.addDep(depManage);
        return R.ok(idadd);
    }
    /**
     * 修改数据
     */
    @PostMapping("/editDep")
    public R editDep(@RequestBody depManage depManage){
        boolean idedit = service.editDep(depManage);
        return R.ok(idedit);
    }
    /**
     * 判断是否有分类车间
     */
    @GetMapping("/hasChildren")
    public R hasChildren(int id){
        return R.ok(service.hasChildren(id));
    }
    /**
     * 单个删除
     */
    @GetMapping("/depId")
    public R depId(int id ){
        boolean isdel = service.depId(id);
        return R.ok(isdel);
    }
}
